package org.oc.qaq.controller;

import io.swagger.v3.oas.annotations.tags.Tag;
import org.oc.qaq.config.OnlyOfficeConfig;
import org.oc.qaq.result.Result;
import org.oc.qaq.service.OnlyOfficeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;
import java.util.Map;

@Tag(name = "OnlyOffice相关接口")
@RestController
@RequestMapping("/api/v1/onlyoffice")
public class OnlyOfficeController {

    @Autowired
    private OnlyOfficeService onlyOfficeService;

    @GetMapping("/config/{fileId}")
    public Result<OnlyOfficeConfig> LoadConfig(@PathVariable String fileId) {
        OnlyOfficeConfig config = onlyOfficeService.LoadConfig(fileId);
        return Result.success(config);
    }

    @PostMapping("/callback")
    public ResponseEntity<Map<String, Object>> callback(@RequestBody Map<String, Object> data) throws IOException {
        return onlyOfficeService.callback(data);
    }
}
